package com.meeting.order.mapper;

import com.meeting.order.domain.Meeting;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface MeetingMapper {
    //插入会议预定
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    int insertMeeting(Meeting meeting);
    
    //检查会议室是否被预定
    int checkBookingConflict(@Param("roomId") String roomId,
                             @Param("startTime") LocalDateTime startTime,
                             @Param("endTime") LocalDateTime endTime);

    //取消会议预定
    int deleteBooking(@Param("id") int id);

    //更新会议预定
    int updateBooking(Meeting meeting);

    //查询会议预定（单个）
    Meeting findBookingByCondition(String bookerName, String roomName, LocalDateTime startDate, LocalDateTime endDate);
    
    //查询会议预定（多个）
    List<Meeting> findBookingsByCondition(@Param("bookerName") String bookerName, 
                                          @Param("roomName") String roomName, 
                                          @Param("startDate") LocalDateTime startDate, 
                                          @Param("endDate") LocalDateTime endDate);
    
    // 查询指定日期范围内的所有会议
    List<Meeting> findMeetingsInDateRange(@Param("startDate") LocalDateTime startDate, 
                                          @Param("endDate") LocalDateTime endDate);
                                          
    // 查询指定会议室在指定时间段内的会议
    List<Meeting> findMeetingsInRoomAndTimeRange(@Param("roomId") String roomId,
                                                 @Param("startTime") LocalDateTime startTime,
                                                 @Param("endTime") LocalDateTime endTime);
}